package com.supermap.business.user;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.order.ServiceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author:langhongshuai
 * @Description:用户功能接口层
 * @Date:18/6/19 上午11:10
 */
@Controller
@RequestMapping("ServiceController")
public class ServiceController {

    /**
     * 使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类
     */
    protected static final Logger logger = LoggerFactory.getLogger(ServiceController.class);


    @Reference
    private ServiceService serviceService;


    /**
     *通过用户id获取用户所有的服务定制信息
     * @param userid
     * @return
     */
    @RequestMapping(method = RequestMethod.POST,path = "getUserService")
    @ResponseBody
    public JSONUtil getUserService(String userid){
        return serviceService.getUserService(userid);
    }

    /**
     * 增加用户服务定制
     * @param userid
     * @param serviceid
     */
    @RequestMapping(method = RequestMethod.POST,path = "addUserService")
    @ResponseBody
    public JSONUtil addUserService(String userid,String serviceid){
        return serviceService.addUserService(userid,serviceid);
    }

    /**
     * 检查用户服务是否已经定制
     * @param userid
     * @param serviceid
     * @return
     */
    @RequestMapping(method = RequestMethod.POST,path = "checkUserServiceExist")
    @ResponseBody
    public JSONUtil checkUserServiceExist(String userid,String serviceid){
        return serviceService.checkUserServiceExist(userid,serviceid);
    }


    /**
     *  删除用户定制服务
     * @param userid
     * @param serviceid
     */
    @RequestMapping(method = RequestMethod.POST,path = "delUserService")
    @ResponseBody
    public JSONUtil delUserService(String userid,String serviceid){
        return serviceService.delUserService(userid,serviceid);
    }
}
